package com.tpfinal.agenda.core;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import com.login.framework.LoginConfig;

public class AgendaConfig implements LoginConfig {

	private String user;
	private String password;
	private String dbName;
	private String server;
	private int loginBlackListTimeInMinutes;

	private static AgendaConfig instance;

	public static AgendaConfig get() {
		if (instance == null) {
			instance = new AgendaConfig();
			instance.load();
		}
		return instance;
	}

	public void load() {

		Properties configFile = new Properties();
		try {

			configFile.load(new FileInputStream("agenda.properties"));

			user = configFile.getProperty("user");
			password = configFile.getProperty("password");
			dbName = configFile.getProperty("db_name");
			server = configFile.getProperty("server");
			loginBlackListTimeInMinutes = Integer.valueOf(configFile
					.getProperty("blacklistminutes"));

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getDbName() {
		return dbName;
	}

	public void setDbName(String db_name) {
		this.dbName = db_name;
	}

	public String getServer() {
		return server;
	}

	public void setServer(String server) {
		this.server = server;
	}

	@Override
	public boolean logEnabled() {
		return true;
	}

	@Override
	public boolean blackListEnabled() {
		return true;
	}

	@Override
	public int blackListTimeInMinutes() {
		return loginBlackListTimeInMinutes;
	}

}
